package Meituan;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author: leiwenkang02@meituan.com
 * @date: 2018/11/12
 * @time: 13:06
 */
public class Test25 {
    public static void main(String[] args) {
        List<Tea> teas = new ArrayList<>();

        Tea stu1 = new Tea(1, 9);
        Tea stu2 = new Tea(1, 8);
        Tea stu3 = new Tea(2, 7);
        teas.add(stu1);
        teas.add(stu2);
        teas.add(stu3);
        Collections.sort(teas, STUDENT_COMPARATOR);

        for (Tea tea : teas) {
            System.out.println(tea.getId() + " " + tea.getAge());
        }

    }

    private static final Comparator<Tea> STUDENT_COMPARATOR = new Comparator<Tea>() {
        @Override
        public int compare(Tea tea1, Tea tea2) {
            if (tea1.getId() == 1 && tea2.getId() == 1) {
                return Integer.compare(tea1.getAge(), tea2.getAge());
            }
            return 0;
        }
    };

}

class Tea {
    int id;
    int age;

    public Tea() {
    }

    public Tea(int id, int age) {
        this.id = id;
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
